package com.study.d3_method_reference;

public class Test4 {
    public static void main(String[] args) {
        //如果某个lambda表达式只是在创建对象，并且参数前后一致，就可以使用构造器引用
//        Create c1 = name -> new Car(name);
        Create c1 = Car::new;
        Car car = c1.createCar("宾利");
        System.out.println(car);
    }
}
@FunctionalInterface
interface Create{
    Car createCar(String name);
}
class Car{
    private String name;

    public Car() {
    }

    public Car(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "Car{" +
                "name='" + name + '\'' +
                '}';
    }

    public void setName(String name) {
        this.name = name;
    }
}
